package com.pic.others.controller;


import cn.hutool.json.JSONUtil;
import com.pic.common.utils.R;
import com.pic.others.constants.category.ConnectionFlaskConstant;
import com.pic.others.domain.Test;
import com.pic.others.domain.dto.category.CategoryWithOnePictureDTO;
import com.pic.others.domain.dto.category.CategoryWithPicturesDTO;
import com.pic.others.domain.dto.picture.PictureFormDTO;
import com.pic.others.domain.po.Category;
import com.pic.others.domain.po.Picture;
import com.pic.others.service.ICategoryService;
import com.pic.others.utils.ConnectionFlaskUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.ArrayList;
import java.util.List;

@Api("关于种类操作")
@RestController
@RequestMapping("/category")
@Slf4j
@RequiredArgsConstructor
public class CategoryController {
    private final ICategoryService categoryService;
    @ApiOperation("用户调用分类接口")
    @GetMapping("/getCategoryInPython")
    public R<String> getCategory(){
        return categoryService.getCategoryInPython();

    }

    @ApiOperation("/用户在查找的时候会显示父类的5张图片，并且展示最新的一张图")
    @GetMapping("/getCategoryWithOnePicture")
    public R< List<CategoryWithPicturesDTO>>getCategoryWithOnePicture(){
        return categoryService.getCategoryWithPicture();
    }

    @ApiOperation("/分类模块获取分类图片")//在分类界面加载这个
    @GetMapping("/getCategoryPictueByFatherOne")
    public R<List<CategoryWithOnePictureDTO>>getCategoryPictureByFatherDTO(){
        return categoryService.getCategoryPictureByFatherDTO();
    }



//用户的操作监听，
  @ApiOperation("/用户点击的时候底下还有文件夹或者是图片(即同一个接口)")
  @GetMapping("/getCategoryPictueByFatherId/{categoryId}")
  public R<List<CategoryWithPicturesDTO>>getCategoryPictueByFatherId(@PathVariable("categoryId") Long categoryId){
      return categoryService.getCategoryPictueByFatherId(categoryId);
  }

//    @ApiOperation("/用户点击的时候底下还有文件夹哦")
//    @GetMapping("/getPictureByCategory/{categoryId}")
//    public R<List<Picture>>getPictureByCategory(@PathVariable("categoryId")Long categoryId){
//        return categoryService.getPictureByCategory(categoryId);
//    }

    @ApiOperation("对分类进行改名")
    @GetMapping("/changeCategoryName/categoryId")
    public R<String>changeCategoryName(@PathVariable("categoryId") Long categoryId,@PathParam("value")String value){
        return categoryService.changeCategoryName(categoryId,value);
    }




}
